package easy;

import java.util.HashSet;
import java.util.Set;

public class Solution_1805 {

    public int numDifferentIntegers(String word) {
        word += " ";
        char[] chars = word.toCharArray();
        Set<String> set = new HashSet<>();
        for (int i = 0, count = 0, zero = 0; i < chars.length; i++) {
            char c = chars[i];
            if (c >= '0' && c <= '9') {
                if (count == 0 && c == '0') {
                    zero++;
                } else {
                    count++;
                }
            } else {
                if (count > 0 || zero > 0) {
                    if (count > 0) {
                        set.add(new String(chars, i - count, count));
                    } else {
                        set.add("0");
                    }
                }
                count = 0;
                zero = 0;
            }
        }
        return set.size();
    }

    public static void main(String[] args) {
        Solution_1805 model = new Solution_1805();
        System.out.println(model.numDifferentIntegers("a123bc34d8ef34"));
        System.out.println(model.numDifferentIntegers("leet1234code234"));
        System.out.println(model.numDifferentIntegers("a1b01c001"));
        System.out.println(model.numDifferentIntegers("0a0"));
//        System.out.println(Integer.parseInt("002010"));
    }
}
